package com.mjfeed.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;

/**
 * @description 论坛回复
 * @author zhaominglei
 * @date 2015年1月10日
 */
@Entity
@Table(name="feed_forum_reply")
public class ForumReply extends BaseEntity implements Serializable {
	private static final long serialVersionUID = -7442355766982497129L;
	/** 论坛话题 **/
	private Long forumTopicId;
	/** 内容 **/
	private String content;
	/** ip **/
	private String ip;
	/** 状态 **/
	private Integer status;
	/** 商品分类 **/
	private ProductCategory productCategory;
	/** 会员 **/
	private Member member;
	
	@Column(name="forum_topic_id")
	public Long getForumTopicId() {
		return forumTopicId;
	}
	public void setForumTopicId(Long forumTopicId) {
		this.forumTopicId = forumTopicId;
	}
	@Column(name="content", columnDefinition="LONGTEXT")
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="product_category_id")
	public ProductCategory getProductCategory() {
		return productCategory;
	}
	public void setProductCategory(ProductCategory productCategory) {
		this.productCategory = productCategory;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="member_id", nullable = false, updatable = false)
	public Member getMember() {
		return member;
	}
	public void setMember(Member member) {
		this.member = member;
	}
	
	/**
	 * 持久化前处理
	 */
	@PrePersist
	public void prePersist() {
		setStatus(0);
	}
	
	/**
	 * 更新前处理
	 */
	@PreUpdate
	public void preUpdate() {
		if (getStatus() == null) {
			setStatus(0);
		}
	}
}
